home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / falcon / programm.ing / nt_dsp1.lzh / NT_DSP1.MSA / FNTNS / SQRT3.ASM < prev    next >
Assembly Source File  |  1989-01-24  |  1KB  |  40 lines

  1. ;
  2. ; This program originally available on the Motorola DSP bulletin board.
  3. ; It is provided under a DISCLAMER OF WARRANTY available from
  4. ; Motorola DSP Operation, 6501 Wm. Cannon Drive W., Austin, Tx., 78735.
  5. ;     
  6. ; Full Precision Square Root by Polynomial Approximation. 
  7. ; Last Update 09 Feb 87   Version 1.0
  8. ;
  9. sqrt3   macro
  10. sqrt3   ident   1,0
  11. ;
  12. ; SQRT3 Macro
  13. ;
  14. ; Full 23 bit precision square root routine using
  15. ; a successive approximation technique.
  16. ;
  17. ; y  = double precision (48 bit) positive input number
  18. ; b  = 24 bit output root
  19. ;
  20. ; a  = temporary storage
  21. ; x0 = guess
  22. ; x1 = bit being tested
  23. ; y1:y0 = input number
  24.  
  25. sqrt3
  26.         clr     b    #<$40,x0           ; init root and guess
  27.         move                    x0,x1   ; init bit to test
  28.         do      #23,_endl
  29.                                         ;START OF LOOP
  30.         mpy     -x0,x0,a                ; square and negate the guess
  31.         add     y,a                     ; compare to double precision input
  32.         tge     x0,b                    ; update root if input >= guess
  33.         tfr     x1,a                    ; get bit to test
  34.         asr     a                               ; shift to next bit to test
  35.         add     b,a             a,x1            ; form new guess
  36.         move                    a,x0            ; save new guess
  37. _endl                                    ;END OF LOOP
  38.         endm
  39.